﻿Imports Microsoft.TeamFoundation.Client
Imports Microsoft.TeamFoundation.WorkItemTracking.Client

Public Class Form1

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
    End Sub

    Private Sub ux_ServerSelection_TeamServerSelected(ByVal TeamServer As Microsoft.TeamFoundation.Client.TeamFoundationServer) Handles ux_ServerSelection.TeamServerSelected
        If TeamServer Is Nothing Then
            Console.WriteLine("Selected team server is invalid. Passing to Project selector...")
            Me.ux_ButtonRefresh.Enabled = False
        Else
            Console.WriteLine("Selected team server {0}. Passing to Project selector...", TeamServer.Name)
        End If
        Me.ux_ProjectSelection.SetTeamServer(TeamServer)
    End Sub

    Private Sub ux_ProjectSelection_TeamProjectSelected(ByVal TeamProject As Microsoft.TeamFoundation.WorkItemTracking.Client.Project) Handles ux_ProjectSelection.TeamProjectSelected
        Console.WriteLine("Selected project {0} from {1}. Passing to xxxx...", TeamProject.Name, TeamProject.Store.TeamFoundationServer.Name)
        Dim SelectedTreeType As Node.TreeType = Node.TreeType.Iteration
        If Not String.IsNullOrEmpty(My.Settings.TeamView) Then
            SelectedTreeType = CType([Enum].Parse(GetType(Node.TreeType), My.Settings.TeamView), Node.TreeType)
        End If
        Me.ux_ProjectDashboard.SetValues(TeamProject, SelectedTreeType)
        Me.ux_ButtonRefresh.Enabled = True
    End Sub

    Private Sub Form1_ResizeEnd(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ResizeEnd
        Me.ux_ProjectDashboard.Refresh()
    End Sub

    Private Sub ux_ViewTypeSelectionControl_TeamViewSelected(ByVal View As Microsoft.TeamFoundation.WorkItemTracking.Client.Node.TreeType) Handles ux_ViewTypeSelectionControl.TeamViewSelected
        Me.ux_ProjectDashboard.SetValue(View)
    End Sub

    Private Sub ux_ButtonRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ux_ButtonRefresh.Click
        Me.ux_ProjectDashboard.Refresh()
    End Sub
End Class
